'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 2_study_operate_pincone_vector.py
* @Time: 2025/8/13
* @All Rights Reserve By Brtc
'''
import dotenv
from langchain_openai import OpenAIEmbeddings
from langchain_pinecone import PineconeVectorStore

dotenv.load_dotenv()
# 1、创建embedding 模型
embedding = OpenAIEmbeddings(model="text-embedding-3-small")
db = PineconeVectorStore(index_name="brtc2online", embedding=embedding, namespace="brtcDataset")
# 删除 数据
#db.delete(["d65085c5-f57a-46cd-ac7c-4da4cd316bf7"])

# 更新数据
# 获取官方实例

pincone_index = db.get_pinecone_index("brtc2online")
print(pincone_index.search(namespace="brtcDataset", query="nihao "))

"""
pincone_index = db.get_pinecone_index("brtc2online")

update_vector = embedding.embed_query("笨笨是一只喜欢乱吃东西的小猫")

print(update_vector)
pincone_index.update(id="203afe5b-3327-4440-ba79-b14371f7e3fa",
                     values=update_vector,
                     set_metadata={"page":20, "text":"笨笨是一只喜欢乱吃东西的小猫"},
                     namespace="brtcDataset")"""